﻿#if (!DEBUG)
using System;
using System.IO;
using System.Windows.Forms;
#endif

namespace MikadoShooter
{
    public static class Program
    {
        public static void Main()
        {
            //Check if all required dll file is existing and loading...
            if (!DllChecker.IsMissingDlls(new[] 
            { 
                "SharpDX.D3DCompiler.dll",
                "SharpDX.Direct3D11.dll",
                "SharpDX.Direct3D11.Effects.dll",
                "SharpDX.DXGI.dll",
                "SharpDX.XAudio2.dll",
                "SharpDX.dll"
            }))
            {
                Game game = null;

                try
                {
                    game = new Game();
                    game.Run();
                }
#if (!DEBUG)
                catch (Exception e)
                {
                    Cursor.Show();

                    using (StreamWriter write = new StreamWriter(@".\MikadoShooter.txt"))
                    {
                        write.WriteLine("Exception:" + e.Message);

                        if (e.InnerException != null)
                            write.WriteLine("InnerException:" + e.InnerException.Message);

                        write.WriteLine("StackTrace" + Environment.NewLine + e.StackTrace.Trim());
                    }
                    MessageBox.Show(e.Message, "Doh!");
                }
#endif
                finally
                {
                    if (game != null) 
                        game.Dispose();
                }
            }
        }
    }
}